

var xmlHttpRequestSI ;
var TCount = 0;
var span;

var IETrueFireFoxFalse ;

if (window.navigator.userAgent.indexOf("MSIE")>=1)
{
    IETrueFireFoxFalse = true ;
}
else if (window.navigator.userAgent.indexOf("Firefox")>=1)
{
    IETrueFireFoxFalse = false ;
}
else
{
    
}

function xmlHttpRequestObjectGet()
{
    var xmlHttpRequestObject ;
    if (!IETrueFireFoxFalse)
    { // Mozilla, Safari, ...
        xmlHttpRequestObject = new XMLHttpRequest();
    }
    else if (IETrueFireFoxFalse) 
    { // IE
        xmlHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
    { // Other
        xmlHttpRequestObject = new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    return xmlHttpRequestObject;
}

function createXmlDoc()
{
    var xmlDoc ;
    
    if (IETrueFireFoxFalse)
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
    }
    else if (!IETrueFireFoxFalse)
    {
        xmlDoc = new DOMParser();
    }
    else
    {
        xmlDoc = new ActiveXObject("Msxml2.XMLDOM"); 
    }
    
    return xmlDoc ;
};

if ( ( typeof(CN) != "undefined" ) )
{
    span = document.getElementById(CN) ; 
    if ( span != null ) 
    {
        if ( 's2.superstat.cn' != document.location.hostname )
        {
            var spanTitle = span.getAttribute("title");
            if ((spanTitle != "" || spanTitle != null) && spanTitle.indexOf("object") == -1) 
                StatInfoCrossDomain() ;
        }
        else
        {
            statInfo();
        }
    }
};

function StatInfoCrossDomain()
{
    if ( typeof(StatType) == "undefined" )
    {
        StatType = 1; 
    }
    
    document.write('<script language="JavaScript" src='+"http://s2.superstat.cn//StatInfoCrossDomain.aspx?f=getReturnValue&webid="+span.title+"&s="+StatType+' type="text/javascript"></script>');
};

function getReturnValue(v)
{
    if ( v != 'undefined' )
    {
        span.innerHTML = v ;
        span.title = "0";
    }
    else
    {
        span.innerHTML = '数据读取中...';
        TCount += 1 ;
        window.setInterval("StatInfoCrossDomain()",500);
    }
    if ( TCount > 5 )
    {
        span.innerHTML = '数据读取失败';
    }
}

function statInfo()
{
    var webId =0;
    var spanName = span.getAttribute("title");
    if ( (spanName != "" || spanName != null) && spanName.indexOf("object") == -1) 
        webId = spanName;
    else
       webId = span.innerHTML;
    spanName = "";
    xmlHttpRequestSI = xmlHttpRequestObjectGet();
    var url = "http://s2.superstat.cn/XHRFuns.aspx?act=stateinfo&webid="+webId;
    xmlHttpRequestSI.onreadystatechange = callBack ;
    xmlHttpRequestSI.open("GET",url, true); 
    xmlHttpRequestSI.send(null); 
}

function callBack()
{
   if( xmlHttpRequestSI.readyState == 4)
    {
        if ( xmlHttpRequestSI.status == 200 )
        {
            var docSubmit =createXmlDoc() ;
            var RStr ;
            
            if ( IETrueFireFoxFalse )
            {
                docSubmit.loadXML(xmlHttpRequestSI.responseTEXT.replace(/&lt;/g,"<").replace(/&gt;/g,">")) ;   
                var nodeList=docSubmit.documentElement.getElementsByTagName("Table");//alert( docSubmit.documentElement.text) ;
		        RStr = nodeList(0).selectSingleNode("Column1").text
            }
            else
            {
                var xmlDoc = new DOMParser();
                var nodeList = xmlDoc.parseFromString( xmlHttpRequestSI.responseText,"text/xml") ;
                RStr = nodeList.childNodes[0].childNodes[1].childNodes[1].childNodes[0].nodeValue;
            }

            RStr=RStr.replace('访问','访问').replace('产品','产品').replace('新闻','新闻').replace('文章','文章');
            
            if ( typeof(StatType) == "undefined" )
            {
	            RStr = RStr.substring(0,RStr.lastIndexOf(','));
		        span.innerHTML = RStr ; 
		    }
	        else if ( StatType == 1 ) 
	        {
	            RStr = RStr.substring(0,RStr.lastIndexOf(','));
		        span.innerHTML = RStr ; 
		    }
	        else if ( StatType == 2 ) 
	        {
		        var arr = new Array() ;
		        arr = RStr.split(",");
		        RStr = arr[0].substring(5);
                span.innerHTML = "<font color=red>" + String.fromCharCode( 24744,26159,26412,31449,31532 ) + " " + RStr + " " + String.fromCharCode( 20301,35775,38382,32773 ) + "</font>" ; 
	        }
	        else if ( StatType == 3 ) 
	        {
	            RStr = RStr.substring(0,RStr.lastIndexOf(','));
		        span.innerHTML = RStr.replace('访问','visitation').replace('产品','product').replace('新闻','news').replace('文章','article');
	            var str = span.innerHTML ;
                var str1 = str.substring(str.indexOf(',')+1);
                var str2 = str1.substr(0,str1.indexOf(',')+1) ;
                span.innerHTML = str.replace(str2,'');
	        }
	        else if ( StatType == 4 ) 
	        {
	            RStr = RStr.substring(0,RStr.lastIndexOf(','));
	            var str = RStr ;
                var str1 = str.substring(str.indexOf(',')+1);
                var str2 = str1.substr(0,str1.indexOf(',')+1) ;
                span.innerHTML = str.replace(str2,'');
	        }
	        else if ( StatType == 5 ) 
	        {
		        var arr = new Array() ;
		        arr = RStr.split(",");
                span.innerHTML = arr[0] + "," + arr[1];
	        }
	        else if ( StatType == 6 ) 
	        {
		        var arr = new Array() ;
		        arr = RStr.split(",");
                span.innerHTML = arr[0] + "," + arr[1] + "," + arr[3] + "," + arr[4];
	        }
	        else if ( StatType == 7 ) 
	        {
	            RStr = RStr.substring(0,RStr.lastIndexOf(','));
		        span.innerHTML = RStr.replace('访问','アクセス').replace('产品','製品').replace('新闻','ニュース').replace('文章','文章');
	            var str = span.innerHTML ;
                var str1 = str.substring(str.indexOf(',')+1);
                var str2 = str1.substr(0,str1.indexOf(',')+1) ;
                span.innerHTML = str.replace(str2,'');
	        }
	        else if ( StatType == 8 ) 
	        {
	            RStr = RStr.substring(0,RStr.lastIndexOf(','));
		        span.innerHTML = RStr.replace('访问','Besuchen').replace('产品','Prudukt').replace('新闻','Nachricht').replace('文章','Artikel');
	        }
	        else if ( StatType == 9 ) 
	        {
	            RStr = RStr.substring(0,RStr.lastIndexOf(','));
		        span.innerHTML = RStr.replace('访问','訪問').replace('产品','産品').replace('新闻','新聞').replace('文章','文章');
	        }
            else if (StatType == 10)
            {
                returnValue = returnValue.Substring(0, returnValue.LastIndexOf(','));
                returnValue = returnValue.Replace(",", " |");
            }
	        else if ( StatType == 12 ) 
	        {
		        var arr = new Array() ;
		        arr = RStr.split(",");
                span.innerHTML = arr[0];
	        }
        }
    }
}